﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace GrayParrot.Web.Formly
{
    [Serializable]
    public class RepeatSectionFieldItem
    {
        [JsonProperty(PropertyName = "className")]
        public DrawDirections ClassName { get; set; }

        [JsonProperty(PropertyName = "fieldGroup")]
        public List<FieldItem> FieldGroup { get; internal set; }

        public RepeatSectionFieldItem()
        {

        }

        public void SetFieldGroup(List<FieldItem> items)
        {
            int m_numeroColonne = (12 / items.Count());

            string m_classNameValue = string.Format("col-xs-{0}", m_numeroColonne);

            foreach (FieldItem item in items)
            {
                item.ClassName = m_classNameValue;
            }

            this.FieldGroup = items;
        }

        public bool ShouldSerializeClassName()
        {
            // don't serialize the Manager property if an employee is their own manager
            return (this.ClassName == DrawDirections.Row);
        }
    }
}
